<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/admin/layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/layuimini/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">上级</label>
        <div class="layui-input-block">
            <select name="parentid" lay-verify="required">
                <option value="0" {if $menuInfo.parentid==0}selected{/if}>顶级菜单</option>
                {volist name="menuList" id="vo"}
                    <option value="{$vo.id}" {if $menuInfo.parentid==$vo.id}selected{/if}>{for start="1" end="$vo.level * 3"}<span>&nbsp;</span>{/for}L {$vo.name}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" placeholder="名称" value="{$menuInfo['name']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">模块</label>
        <div class="layui-input-block">
            <input type="text" name="app" lay-verify="required" lay-reqtext="模块不能为空" placeholder="模块" value="{$menuInfo['app']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">控制器</label>
        <div class="layui-input-block">
            <input type="text" name="controller" lay-verify="required" lay-reqtext="控制器不能为空" placeholder="控制器" value="{$menuInfo['controller']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">方法</label>
        <div class="layui-input-block">
            <input type="text" name="action" lay-verify="required" lay-reqtext="方法不能为空" placeholder="方法" value="{$menuInfo['action']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">参数</label>
        <div class="layui-input-block">
            <input type="text" name="parameter" placeholder="参数" value="{$menuInfo['parameter']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">备注</label>
        <div class="layui-input-block">
            <input type="text" name="remark" placeholder="备注" value="{$menuInfo['remark']}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">类型</label>
        <div class="layui-input-block">
            <input type="radio" name="type" value="1" title="权限菜单" {if $menuInfo.type == 1}checked{/if}>
            <input type="radio" name="type" value="0" title="菜单组" {if $menuInfo.type == 0}checked{/if}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="显示" {if $menuInfo.status == 1}checked{/if}>
            <input type="radio" name="status" value="0" title="不显示" {if $menuInfo.status == 0}checked{/if}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图标</label>
        <div class="layui-input-block">
            <input type="email" name="icon" placeholder="图标" value="{$menuInfo['icon']}" class="layui-input">
        </div>
    </div>
    <input type="hidden" name="id" value="{$menuInfo['id']}">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="/static/admin/layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: "{:url('menu/edit')}",
                type: 'post',
                dataType: 'json',
                data:data.field,
                success: function (data) {
                    layer.msg(data.msg);
                    //添加成功
                    if(data['status']){
                        setTimeout(function(){
                            if(window !== parent.window) parent.window.layer.closeAll();
                        }, 1000)
                    }
                },
                error: function (xhr, textstatus, thrown) {
                    return layer.msg('Status:' + xhr.status + '，' + xhr.statusText + '，请稍后再试！');
                }
            });

            return false;
        });

    });
</script>
</body>
</html>